package com.yide.myworld.constants.enums;

import com.yide.myworld.api_result.IEnumCode;

import java.util.*;

public enum DelayLevelEnum implements IEnumCode {

    // 1s
    DELAY_LEVEL_1("1", "1"),
    // 5s
    DELAY_LEVEL_2("5", "2"),
    // 10s
    DELAY_LEVEL_3("10", "3"),
    // 30s
    DELAY_LEVEL_4("30", "4"),
    // 1m
    DELAY_LEVEL_5("60", "5"),
    // 2m
    DELAY_LEVEL_6("120", "6"),
    // 3m
    DELAY_LEVEL_7("180", "7"),
    // 4m
    DELAY_LEVEL_8("240", "8"),
    // 5m
    DELAY_LEVEL_9("300", "9"),
    // 6m
    DELAY_LEVEL_10("360", "10"),
    // 7m
    DELAY_LEVEL_11("420", "11"),
    // 8m
    DELAY_LEVEL_12("480", "12"),
    // 9m
    DELAY_LEVEL_13("540", "13"),
    // 10m
    DELAY_LEVEL_14("600", "14"),
    // 20m
    DELAY_LEVEL_15("1200", "15"),
    // 30m
    DELAY_LEVEL_16("1800", "16"),
    // 1h
    DELAY_LEVEL_17("3600", "17"),
    // 2h
    DELAY_LEVEL_18("7200", "18"),

    ;
    private final String code;
    private final String message;

    @Override
    public String getCode() {
        return this.code;
    }

    @Override
    public String getMessage() {
        return this.message;
    }

    DelayLevelEnum(final String code, final String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据编码查找枚举
     *
     * @param code 编码
     * @return {@link DelayLevelEnum } 实例
     **/
    public static DelayLevelEnum find(String code) {
        return Arrays.stream(values()).filter((input) -> input.getCode().equals(code)).findFirst().orElse(DELAY_LEVEL_6);
    }
}